Component({
    properties: {},
    data: {
        src: 'http://ekko-pi.oss-cn-beijing.aliyuncs.com/face.jpg',
        hour: '',
        minute: '',
        second: '',
        flag: 0,
    },
    methods: {
        getPhoto() {
                const date = new Date();
                this.data.hour = date.getHours();
                this.data.minute = date.getMinutes();
                // if (this.data.minute < 10) {
                //     this.data.minute = '0' + this.data.minute;
                // }
                this.data.second = date.getSeconds();
                // if (this.data.second < 10) {
                //     this.data.second = '0' + this.data.second;
                // }
                this.data.flag = this.data.hour + '' + this.data.minute + '' + this.data.second;
            this.setData({
                src: 'https://ekko-pi.oss-cn-beijing.aliyuncs.com/'+this.data.flag+'face.jpg',
            });
            console.log('获取图片')
            console.log(this.data.src);
        },
        //重新渲染组件



    },
    lifetimes: {
        attached: function () {
            this.getPhoto();
            this.data.timer = setInterval(() => {
                this.getPhoto();
                //清除所有缓存
                wx.clearStorage();
            },100000);
        },
        detached() {
            // 在组件实例被从页面节点树移除时执行
            clearInterval(this.data.timer);
        }
    },
    pageLifetimes: {
        show() {
            this.getPhoto();
        }
    }
});
